package com.seeyon.apps.ningbobank.action;

import com.seeyon.apps.ningbobank.manager.NingBoBankSuperNodeManager;
import com.seeyon.cap4.form.bean.FormBean;
import com.seeyon.cap4.form.bean.FormDataMasterBean;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.common.log.CtpLogFactory;
import com.seeyon.ctp.util.annotation.Inject;
import com.seeyon.ctp.workflow.supernode.BaseSuperNodeAction;
import com.seeyon.ctp.workflow.supernode.SuperNodeResponse;
import org.apache.commons.logging.Log;

import java.util.Map;

/**
 * @ClassName NingBoBankSuperNodeAction
 * @Description 宁波银行超级节点
 * @Author CheungHowrAn
 * @Date 2023/8/16 10:14
 * @PackageName com.seeyon.apps.ningbobank.action
 * @ProjectName BSiEE本涩_A8_V9.0SP1
 */
public class NingBoBankSuperNodeAction extends BaseSuperNodeAction {

    private static final long serialVersionUID = -8375373865408149606L;

    private static Log log = CtpLogFactory.getLog(NingBoBankSuperNodeAction.class);
    @Inject
    private  NingBoBankSuperNodeManager ningBoBankSuperNodeManager;


    @Override
    public int getOrder() {
        return 0;
    }

    @Override
    public String getNodeId() {
        return "ningBoBankSuperNodeAction";
    }

    @Override
    public String getNodeName() {
        return "宁波银行付款超级节点";
    }

    /**
     * @MethodName executeAction
     * @Description 超级节点动作执行方法
     * @param: token
     * @param: activityId
     * @param: params
     * @return: com.seeyon.ctp.workflow.supernode.SuperNodeResponse
     * @Author CheungHowrAn
     * @Date 2023/8/19 13:10
     */
    @Override
    public SuperNodeResponse executeAction(String token, String activityId, Map<String, Object> params) throws BusinessException {
        log.info("==============触发超级节点动作执行方法==============");
        Map<String, Object> ctpFormData = (Map<String, Object>) params.get("CTP_FORM_DATA");
        FormDataMasterBean formDataMasterBean = (FormDataMasterBean) ctpFormData.get("formDataBean");
        FormBean formBean = (FormBean) ctpFormData.get("formBean");
        SuperNodeResponse superNodeResponse = ningBoBankSuperNodeManager.executeAction(token, formBean, formDataMasterBean);
        return superNodeResponse;
    }

    /**
     * @MethodName confirmAction
     * @Description 确认超级节点动作执行情况
     * @param: token
     * @param: activityId
     * @param: params
     * @return: com.seeyon.ctp.workflow.supernode.SuperNodeResponse
     * @Author CheungHowrAn
     * @Date 2023/8/19 13:10
     */
    @Override
    public SuperNodeResponse confirmAction(String token, String activityId, Map<String, Object> params) throws BusinessException {
        return executeAction(token, activityId, params);
    }


    /**
     * @MethodName cancelAction
     * @Description 超级节点动作撤销方法
     * @param: superNodeId
     * @param: activityId
     * @param: params
     * @Author CheungHowrAn
     * @Date 2023/8/19 13:09
     */
    @Override
    public void cancelAction(String superNodeId, String activityId, Map<String, Object> params) throws BusinessException {
        log.info("超级节点撤销事件触发,superNodeId=" + superNodeId);
    }

}
